In [114]:
from sympy import *
from sympy import abc
from IPython.display import display, Math, Latex
from sympy.interactive import printing
printing.init_printing(use_latex=True)
In [121]:
t, x, u= symbols('t x u')
Vt, Vx = symbols('V_t V_x')
f = x + 0.5 * u**2
b = x + u
In [122]:
hjbeq = r'\frac{\partial V}{\partial t} + \min_u \left[' + latex(f) + r'+\frac{\partial V}{\partial x}\left(' + latex(b)+ r'\right)\right] = 0'
display(Math(hjbeq))
hjbbd = r'V(T,x)=0'
display(Math(hjbbd))
In [123]:
sahjbeq = r'\frac{\partial V_k}{\partial t} + ' + latex(f) + r'+\frac{\partial V_k}{\partial x} \left(' + latex(b) + r'\right)= 0'
display(Math(sahjbeq.replace('u', 'u_k')))
sahjbbd = r'V_k(T,x)=0'
display(Math(sahjbbd))
In [124]:
update = r'u_{k+1} = \arg\min_{u_k}\left[' + latex(f) + r'+\frac{\partial V_k}{\partial x} \left(' + latex(b) + r'\right)\right]'
display(Math(update))
In [ ]: